$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    console.log('detail Ready');

    var mstform = $NG.getCmpApi('ConCheckUpForm');
    console.log(mstform);
    //  init 
    getCntPsandQd()
    useBeforeClick(() => {
        if (window._catch_saveLock) {
            $NG.alert("该标段名称下方已包含一条合同评审与签订的数据，请勿重复创建！")
            return false
        }
    }, "save")
    useValuesChange(({ args }) => {
        setHiddenChryPsjg()
    }, "ConCheckUpForm.user_htps");
    useValuesChange(({ args }) => {
        console.log(`项目选择`,);
        let PhidPc = mstform.getItem('PhidPc').getValue()
        $NG.execServer(
            "searchXmxx",
            { u_bdmc: PhidPc },
            function (res) {
                console.log(res);

                if (res.count > 0) {
                    var obj = JSON.parse(res.data);
                    console.log(obj);
                    mstform.getItem('user_xmmc').setValue(obj[0].extendObjects.u_xmbmc)
                    mstform.getItem('user_xmbh').setValue(obj[0].extendObjects.bill_no)
                    mstform.getItem('user_gzjb').setValue(obj[0].extendObjects.u_gzjb)
                }
            }
        );
        getCntPsandQd()
        getTraceProjectInfo()
    }, "ConCheckUpForm.PhidPc");
    // 参会人员 评审结果人员控制
    function setHiddenChryPsjg() {
        let user_htps = mstform.getItem('user_htps').getValue();
        console.log("当前user_htps值:", user_htps);
        if (user_htps == '01') {
            console.log(`吟唱`,);
            $NG.updateUI((updater) => {
                const fields = ["user_chry", 'user_psjg'];
                fields.forEach((field) => {
                    updater.fieldSetForm.ConCheckUpForm[field].setProps({
                        hidden: true, //隐藏
                        required: false, //必输
                        // disabled: true, //只读
                    });
                });
            });
        } else {
            $NG.updateUI((updater) => {
                const fields = ["user_chry", 'user_psjg'];
                fields.forEach((field) => {
                    updater.fieldSetForm.ConCheckUpForm[field].setProps({
                        hidden: false, //隐藏
                        required: true, //必输
                        // disabled: true, //只读
                    });
                });
            });
        }
    }
    function getCntPsandQd() {
        const phid = mstform.getItem("PhidPc").getValue()
        const source_phid = mstform.getValues().PhId || '0'
        console.log(`soutde`, source_phid);
        if (!phid) return
        $NG.execServer("getCntPsandQd", { bdmc: phid, phid: source_phid }, (res) => {
            if (res.count == 0) {
                window._catch_saveLock = false
                return
            }
            $NG.alert("该标段名称下方已包含一条合同评审与签订的数据，请勿重复创建！")
            window._catch_saveLock = true
        })
    }

    // 获取跟踪项目信息
    function getTraceProjectInfo(){
        const phid = mstform.getItem("PhidPc").getValue()
        if(!phid) return 
        $NG.execServer("getProjectInfoByPhid",{phid},(res)=>{
            if(res.count == 0) return 
            const datas = JSON.parse(res.data)[0].extendObjects
            console.log(`datas`,datas);
            mstform.getItem("user_xmbh").setValue(datas.bill_no)
            mstform.getItem("user_xmmc").setValue(datas.bill_name)
            mstform.getItem("user_gzjb").setValue(datas.user_gzjb)
        })

    }
}, function () {
    console.log('list Ready');
});